﻿using System;
using System.Collections.Generic;
using System.Drawing;
using UserData;

namespace StationDemo
{

    public enum SOCKET
    {
        SOCKETA,
        SOCKETB
    }


    public enum SOCKETSTATUS
    {
        // 没产品
        NoProduct,
        // 有产品不可测试
        HaveProductCantTest,
        // 有产品可测试
        HaveProductCanTest,
        // 有产品测试中
        HaveProductTestIng,
        // 有产品测试完成
        HaveProductTestEnd
    }



    public class ProductData
    {
        public TestInfo ST { get; set; } = new TestInfo { Name = "时间", Value = "", Max = " ", Min = " " };

        public TestInfo sn { get; set; } = new TestInfo { Name = "SN", Value = "", Max = " ", Min = " " };

        public TestInfo socketName { get; set; } = new TestInfo { Name = "治具名称", Value = "", Max = " ", Min = " " };

        public TestInfo result { get; set; } = new TestInfo { Name = "结果", Value = false, Max = " ", Min = " " };

        public TestInfo reproErr { get; set; } = new TestInfo { Name = "重投影误差", Value = float.NaN, Max = " ", Min = " " };
        public TestInfo coverage { get; set; } = new TestInfo { Name = "覆盖率", Value = float.NaN, Max = " ", Min = " " };
        public TestInfo fx { get; set; } = new TestInfo { Name = "fx", Value = double.NaN, Max = " ", Min = " " };
        public TestInfo fy { get; set; } = new TestInfo { Name = "fy", Value = double.NaN, Max = " ", Min = " " };
        public TestInfo Cx { get; set; } = new TestInfo { Name = "Cx", Value = double.NaN, Max = " ", Min = " " };
        public TestInfo Cy { get; set; } = new TestInfo { Name = "Cy", Value = double.NaN, Max = " ", Min = " " };
        public TestInfo K1 { get; set; } = new TestInfo { Name = "K1", Value = double.NaN, Max = " ", Min = " " };
        public TestInfo K2 { get; set; } = new TestInfo { Name = "K2", Value = double.NaN, Max = " ", Min = " " };
        public TestInfo K3 { get; set; } = new TestInfo { Name = "K3", Value = double.NaN, Max = " ", Min = " " };
        public TestInfo K4 { get; set; } = new TestInfo { Name = "K4", Value = double.NaN, Max = " ", Min = " " };
        public TestInfo K5 { get; set; } = new TestInfo { Name = "K5", Value = double.NaN, Max = " ", Min = " " };
        public TestInfo K6 { get; set; } = new TestInfo { Name = "K6", Value = double.NaN, Max = " ", Min = " " };
        public TestInfo P1 { get; set; } = new TestInfo { Name = "P1", Value = double.NaN, Max = " ", Min = " " };
        public TestInfo P2 { get; set; } = new TestInfo { Name = "P2", Value = double.NaN, Max = " ", Min = " " };
    }


    public class StationInfor
    {
        public DateTime startTime = DateTime.Now;

        public SOCKET socket { get; set; } = SOCKET.SOCKETA;

        public SOCKETSTATUS SOCKETSTATUS { get; set; } = SOCKETSTATUS.NoProduct;

        public ProductData productData { get; set; } = new ProductData();


        public StationInfor(SOCKET socket)
        {
            this.socket = socket;
        }
    }





    //public class DeviceData
    //{
    //    public static string str_点胶产品SN = "默认SN";
    //    public static string str_点胶载具SN = "默认SN";

    //    public static string str_组装产品SN = "默认SN";
    //    public static string str_组装载具SN = "默认SN";
    //}


    //[Serializable]
    //public class ProductData
    //{
    //    public bool b_IsWork = true;
    //    public bool b_IsHaveProduct = false;
    //    public int sockeNum = 0;
    //    public int bitmapNum = 3;
    //   // public LoadServer loadServer = null;
    //    public Dictionary<string, int> resultState = new Dictionary<string, int>();
    //    public ResultDataBase result;
    //    public ProductData Get_CloneObject()
    //    {
    //        using (Stream objectStream = new MemoryStream())
    //        {
    //            IFormatter formatter = new BinaryFormatter();
    //            formatter.Serialize(objectStream, this);
    //            objectStream.Seek(0, SeekOrigin.Begin);
    //            return (ProductData)formatter.Deserialize(objectStream);
    //        }

    //    }
    //}

    ///* 算法类型     0：CalibNormalTest
    //                1：CalibRationalTest
    //                2：CalibFisheyeTest
    //                3：CalibMEITest
    //                4：CalibDivisionTest

    // * 不同算法类型下，标定软件回传的数据
    // *  CalibNormalTest：reproErr_Cx_Cy_fx_fy_k0_k1_k2_k3_p0_p1
    //    CalibRationalTest：reproErr_Cx_Cy_fx_fy_k0_k1_k2_k3_k4_k5_p0_p1
    //    CalibFisheyeTest：reproErr_Cx_Cy_fx_fy_k0_k1_k2_k3
    //    CalibMEITest：reproErr_Cx_Cy_fx_fy_k0_k1_p0_p1_meiXi
    //    CalibDivisionTest：reproErr_Cx_Cy_fx_fy_k0_k1_k2_k3

    // */

    ////[Serializable]
    ////public class ResultData:ResultDataBase
    ////{

    ////    public TestInfo reproErr { get; set; } = new TestInfo { Name = "重投影误差", Value = float.NaN, Max = " ", Min = " " };
    ////    public TestInfo fx { get; set; } = new TestInfo { Name = "fx", Value = float.NaN, Max = " ", Min = " " };
    ////    public TestInfo fy { get; set; } = new TestInfo { Name = "fy", Value = float.NaN, Max = " ", Min = " " };
    ////    public TestInfo Cx { get; set; } = new TestInfo { Name = "Cx", Value = float.NaN, Max = " ", Min = " " };
    ////    public TestInfo Cy { get; set; } = new TestInfo { Name = "Cy", Value = float.NaN, Max = " ", Min = " " };
    ////    public TestInfo K1 { get; set; } = new TestInfo { Name = "K1", Value = float.NaN, Max = " ", Min = " " };
    ////    public TestInfo K2 { get; set; } = new TestInfo { Name = "K2", Value = float.NaN, Max = " ", Min = " " };
    ////    public TestInfo K3 { get; set; } = new TestInfo { Name = "K3", Value = float.NaN, Max = " ", Min = " " };
    ////    public TestInfo K4 { get; set; } = new TestInfo { Name = "K4", Value = float.NaN, Max = " ", Min = " " };
    ////    public TestInfo K5 { get; set; } = new TestInfo { Name = "K5", Value = float.NaN, Max = " ", Min = " " };
    ////    public TestInfo K6 { get; set; } = new TestInfo { Name = "K6", Value = float.NaN, Max = " ", Min = " " };


    ////}
    //[Serializable]
    //public class ResultData : ResultDataBase
    //{

    //    public TestInfo RMS_Mean { get; set; } = new TestInfo { Name = "平均重投影", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo RMS_Max { get; set; } = new TestInfo { Name = "最大重投影", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo Coverage { get; set; } = new TestInfo { Name = "覆盖率", Value = double.NaN, Max = " ", Min = " ", IsUse = false };

    //    public TestInfo Cx { get; set; } = new TestInfo { Name = "Cx", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo Cy { get; set; } = new TestInfo { Name = "Cy", Value = double.NaN, Max = " ", Min = " ",IsUse = false};
    //    public TestInfo fx { get; set; } = new TestInfo { Name = "fx", Value = double.NaN, Max = " ", Min = " ",IsUse = false};
    //    public TestInfo fy { get; set; } = new TestInfo { Name = "fy", Value = double.NaN, Max = " ", Min = " ",IsUse = false};


    //    public TestInfo K0 { get; set; } = new TestInfo { Name = "K0", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo K1 { get; set; } = new TestInfo { Name = "K1", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo K2 { get; set; } = new TestInfo { Name = "K2", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    // //   public TestInfo K3 { get; set; } = new TestInfo { Name = "K3", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo P0 { get; set; } = new TestInfo { Name = "P0", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo P1 { get; set; } = new TestInfo { Name = "P1", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};


    //}

    //[Serializable]
    //public class ResultData1 : ResultDataBase
    //{

    //    public TestInfo RMS_Mean { get; set; } = new TestInfo { Name = "平均重投影", Value = 0.0, Max = " ", Min = " " , IsUse = false };
    //    public TestInfo RMS_Max { get; set; } = new TestInfo { Name = "最大重投影", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo Coverage { get; set; } = new TestInfo { Name = "覆盖率", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo Cx { get; set; } = new TestInfo { Name = "Cx", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo Cy { get; set; } = new TestInfo { Name = "Cy", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo fx { get; set; } = new TestInfo { Name = "fx", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo fy { get; set; } = new TestInfo { Name = "fy", Value = double.NaN, Max = " ", Min = " " ,IsUse = false };


    //    public TestInfo K0 { get; set; } = new TestInfo { Name = "K0", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo K1 { get; set; } = new TestInfo { Name = "K1", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo K2 { get; set; } = new TestInfo { Name = "K2", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo K3 { get; set; } = new TestInfo { Name = "K3", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo K4 { get; set; } = new TestInfo { Name = "K4", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo K5 { get; set; } = new TestInfo { Name = "K5", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};                                                                     
    //    public TestInfo P0 { get; set; } = new TestInfo { Name = "P0", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo P1 { get; set; } = new TestInfo { Name = "P1", Value = double.NaN, Max = " ", Min = " ", IsUse = false };


    //}
    //[Serializable]
    //public class ResultData2 : ResultDataBase
    //{

    //    public TestInfo RMS_Mean { get; set; } = new TestInfo { Name = "平均重投影", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo RMS_Max { get; set; } = new TestInfo { Name = "最大重投影", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo Coverage { get; set; } = new TestInfo { Name = "覆盖率", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo Cx { get; set; } = new TestInfo { Name = "Cx", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo Cy { get; set; } = new TestInfo { Name = "Cy", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo fx { get; set; } = new TestInfo { Name = "fx", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo fy { get; set; } = new TestInfo { Name = "fy", Value = double.NaN, Max = " ", Min = " ", IsUse = false };


    //    public TestInfo K0 { get; set; } = new TestInfo { Name = "K0", Value = double.NaN, Max = " ", Min = " ",IsUse = false};
    //    public TestInfo K1 { get; set; } = new TestInfo { Name = "K1", Value = double.NaN, Max = " ", Min = " ",IsUse = false};
    //    public TestInfo K2 { get; set; } = new TestInfo { Name = "K2", Value = double.NaN, Max = " ", Min = " ",IsUse = false};
    //    public TestInfo K3 { get; set; } = new TestInfo { Name = "K3", Value = double.NaN, Max = " ", Min = " ", IsUse = false };

    //}
    //[Serializable]
    //public class ResultData3 : ResultDataBase
    //{

    //    public TestInfo RMS_Mean { get; set; } = new TestInfo { Name = "平均重投影", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo RMS_Max { get; set; } = new TestInfo { Name = "最大重投影", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo Coverage { get; set; } = new TestInfo { Name = "覆盖率", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo Cx { get; set; } = new TestInfo { Name = "Cx", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo Cy { get; set; } = new TestInfo { Name = "Cy", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo fx { get; set; } = new TestInfo { Name = "fx", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo fy { get; set; } = new TestInfo { Name = "fy", Value = double.NaN, Max = " ", Min = " ", IsUse = false };


    //    public TestInfo K0 { get; set; } = new TestInfo { Name = "K0", Value = double.NaN, Max = " ", Min = " ",IsUse = false};
    //    public TestInfo K1 { get; set; } = new TestInfo { Name = "K1", Value = double.NaN, Max = " ", Min = " ", IsUse = false };


    //    public TestInfo P0 { get; set; } = new TestInfo { Name = "P0", Value = double.NaN, Max = " ", Min = " " ,IsUse = false};
    //    public TestInfo P1 { get; set; } = new TestInfo { Name = "P1", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo MeiXi { get; set; } = new TestInfo { Name = "MeiXi", Value = double.NaN, Max = " ", Min = " ", IsUse = false };

    //}

    //[Serializable]
    //public class ResultData5 : ResultDataBase
    //{

    //    public TestInfo RMS_Mean { get; set; } = new TestInfo { Name = "平均重投影", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo RMS_Max { get; set; } = new TestInfo { Name = "最大重投影", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo Coverage { get; set; } = new TestInfo { Name = "覆盖率", Value = double.NaN, Max = " ", Min = " ", IsUse = false };

    //    public TestInfo Cx { get; set; } = new TestInfo { Name = "Cx", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo Cy { get; set; } = new TestInfo { Name = "Cy", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo PolyCoeffs1 { get; set; } = new TestInfo { Name = "PolyCoeffs1", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo PolyCoeffs2 { get; set; } = new TestInfo { Name = "PolyCoeffs2", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo PolyCoeffs3 { get; set; } = new TestInfo { Name = "PolyCoeffs3", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo PolyCoeffs4 { get; set; } = new TestInfo { Name = "PolyCoeffs4", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo PolyCoeffs5 { get; set; } = new TestInfo { Name = "PolyCoeffs5", Value = double.NaN, Max = " ", Min = " ", IsUse = false };

    //    public TestInfo InvPoly1 { get; set; } = new TestInfo { Name = "InvPoly1", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly2 { get; set; } = new TestInfo { Name = "InvPoly2", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly3 { get; set; } = new TestInfo { Name = "InvPoly3", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly4 { get; set; } = new TestInfo { Name = "InvPoly4", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly5 { get; set; } = new TestInfo { Name = "InvPoly5", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly6 { get; set; } = new TestInfo { Name = "InvPoly6", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly7 { get; set; } = new TestInfo { Name = "InvPoly7", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly8 { get; set; } = new TestInfo { Name = "InvPoly8", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly9 { get; set; } = new TestInfo { Name = "InvPoly9", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly10 { get; set; } = new TestInfo { Name = "InvPoly10", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly11 { get; set; } = new TestInfo { Name = "InvPoly11", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly12 { get; set; } = new TestInfo { Name = "InvPoly12", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly13 { get; set; } = new TestInfo { Name = "InvPoly13", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly14 { get; set; } = new TestInfo { Name = "InvPoly14", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly15 { get; set; } = new TestInfo { Name = "InvPoly15", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly16 { get; set; } = new TestInfo { Name = "InvPoly16", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly17 { get; set; } = new TestInfo { Name = "InvPoly17", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly18 { get; set; } = new TestInfo { Name = "InvPoly18", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly19 { get; set; } = new TestInfo { Name = "InvPoly19", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo InvPoly20 { get; set; } = new TestInfo { Name = "InvPoly20", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo AffineParas1 { get; set; } = new TestInfo { Name = "AffineParas1", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo AffineParas2 { get; set; } = new TestInfo { Name = "AffineParas2", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo AffineParas3 { get; set; } = new TestInfo { Name = "AffineParas3", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo AffineParas4 { get; set; } = new TestInfo { Name = "AffineParas4", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo AffineParas5 { get; set; } = new TestInfo { Name = "AffineParas5", Value = double.NaN, Max = " ", Min = " ", IsUse = false };


    //}


    //[Serializable]
    //public class ResultDataBase
    //{
    //    public TestInfo str_机型 { get; set; } = new TestInfo { Name = "机型", Value = "", Max = " ", Min = " " };
    //    public TestInfo str_批次 { get; set; } = new TestInfo { Name = "批次", Value = "", Max = " ", Min = " " };
    //    public TestInfo str_操作者 { get; set; } = new TestInfo { Name = "设备操作者", Value = "", Max = " ", Min = " " };
    //    public TestInfo str_设备编号 { get; set; } = new TestInfo { Name = "设备编号", Value = "", Max = " ", Min = " " };
    //    public TestInfo str_工站编号 { get; set; } = new TestInfo { Name = "工站编号", Value = "", Max = " ", Min = " " };
    //    public TestInfo str_治具编号 { get; set; } = new TestInfo { Name = "治具号", Value = "", Max = " ", Min = " " };
    //    public TestInfo str_外壳SN { get; set; } = new TestInfo { Name = "外壳SN", Value = "", Max = " ", Min = " " };
    //    public TestInfo FailStep { get; set; } = new TestInfo { Name = "NG原因", Value = "", Max = " ", Min = " " };
    //    public TestInfo StarTime { get; set; } = new TestInfo { Name = "开始时间", Value = DateTime.Now, Max = " ", Min = " " };
    //    public TestInfo EndTime { get; set; } = new TestInfo { Name = "结束时间", Value = DateTime.Now, Max = " ", Min = " " };
    //    public TestInfo TestTime { get; set; } = new TestInfo { Name = "测试时间", Value = 0.00, Max = " ", Min = " " };
    //    public TestInfo Result { get; set; } = new TestInfo { Name = "测试结果", Value = true, Max = " ", Min = " " };
    //    public TestInfo PlayResult { get; set; } = new TestInfo { Name = "点亮结果", Value = true, Max = " ", Min = " " };
    //    public TestInfo CalibResult { get; set; } = new TestInfo { Name = "标定结果", Value = true, Max = " ", Min = " " };

    //    public TestInfo Current { get; set; } = new TestInfo { Name = "电流", Value = double.NaN, Max = " ", Min = " ", IsUse = false };
    //    public TestInfo Voltage { get; set; } = new TestInfo { Name = "电压", Value = double.NaN, Max = " ", Min = " ", IsUse = false };


    //}

}